﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebServices;

namespace Viewer
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            //Service1 service = new Service1();

            Label2.Text = "Sending";
            float latitude = float.Parse(LatitudeBox.Text);
            float longitude = float.Parse(LongitudeBox.Text);
            CreatePlace(PlaceName.Text, " ", latitude, longitude);


            Label2.Text = "Saved";
        }

        public void CreatePlace(string name, string description, float latitude, float longitude)
        {
            string location = "POINT(" + latitude + " " + longitude + ")";
            CommonConnection.Instance().CreateConnection();
            //CommonConnection.Instance().executeSQL("INSERT INTO Place (name,description,location) VALUES ('" + name + "','" + description + "',GeomFromText( '" + location + "'))");

            CommonConnection.Instance().executeSQL("INSERT INTO Place (name,description,location) VALUES ('" + name + "','" + description + "',GeomFromText( '" + location + "'))");

        }
    }
}
